<?php
$isMobile = preg_match("/(Android|iPhone|SymbianOS|Windows Phone|iPad|iPod)/i", request()->header('User-Agent'));
?>
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <!-- 360浏览器急速模式 -->
    <meta name="renderer" content="webkit"/>
    <meta name="force-rendering" content="webkit"/>
    <!-- 避免IE使用兼容模式 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
    <meta http-equiv="expires" content="0">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta name="description" content="<?=params('site_name')?>">
    <title><?= params('site_name') ?></title>
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->
    <link href="/favicon.ico" rel="stylesheet"/>
    <link href="/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="/css/jquery.contextMenu.min.css" rel="stylesheet"/>
    <link href="/css/font-awesome.min.css" rel="stylesheet"/>
    <link href="/css/animate.css" rel="stylesheet"/>
    <link href="/css/skins.css" rel="stylesheet"/>
    <link href="/css/style.css" rel="stylesheet"/>
    <link href="/xunshan/css/xs-ui.css" rel="stylesheet"/>
    <link href="/css/floating.css" rel="stylesheet" type="text/css">
</head>
<body class="fixed-sidebar full-height-layout gray-bg skin-blue theme-dark <?= $isMobile ? 'canvas-menu' : '' ?>"
      style="overflow: hidden">
<div id="wrapper">
    <!--左侧导航开始-->
    <nav class="navbar-default navbar-static-side" role="navigation"
         style="display: <?= $isMobile ? 'none' : 'block' ?>">
        <div class="nav-close">
            <i class="fa fa-times-circle"></i>
        </div>
        <a href="javascript:void(0);">
            <li class="logo hidden-xs">
                <span class="logo-mini"><?= params('short_site_name'); ?></span>
                <span class="logo-lg"><?= params('site_name'); ?></span>
            </li>
        </a>
        <!--菜单搜索框 start-->
        <a id="hiddenUrl" src='' style='display:none;'></a>
        <!--菜单搜索框 end-->
        <form action="" method="get" class="sidebar-form" onsubmit="return false;">
            <div class="input-group">
                <input type="text" name="q" class="form-control" placeholder="搜索菜单">
                <span class="input-group-btn">
                            <button type="submit" name="search" id="search-btn" class="btn btn-flat"><i
                                        class="fa fa-search"></i>
                            </button>
                        </span>
            </div>
            <div class="menuresult list-group sidebar-form hide"
                 style="width:180px;margin: 0;position: absolute;z-index: 9999;max-height:50vh;overflow-y:scroll;">
            </div>
        </form>
        <div class="sidebar-collapse tab-content" id="side-menu">
            <ul class="nav">
                <li class="mobile-device-loginout">
                    <a class="logout noactive"
                       href="javascript:$.modal.confirm('确定退出登录吗？',function(){window.location.href='/backend/login/logout';});">
                        <i class="fa fa-sign-out"></i> 退出登录</a>
                </li>
                <li class="active selected">
                    <a class="menuItem" href="/backend/dashboard/index"><i class="fa fa-dashboard"></i> <span
                                class="nav-label">仪表盘</span> </a>
                </li>

                <!-- 构建菜单开始 -->
                <?php
                $menus = menus();
                foreach ($menus as $menu): ?>
                    <li>
                        <a class="<?= (!empty($menu['action']) && $menu['action'] != '#') ? 'menuItem' : '' ?>"
                           href="<?= empty($menu['url']) ? 'javascript:void(0)' : $menu['url'] ?>">
                            <i class="<?= $menu['icon'] ?>"></i>
                            <span class="nav-label"><?= $menu['menu_name'] ?></span>
                            <span class="<?= (empty($menu['action']) || $menu['action'] == '#') ? 'fa arrow' : '' ?>"></span>
                        </a>
                        <ul class="nav nav-second-level collapse">
                            <?php foreach ($menu['child_menus'] as $cmenu): ?>
                                <li>
                                    <?php if (empty($cmenu['child_menus'])) : ?>
                                        <a class="menuItem" href="<?= $cmenu['action'] ?>"><i class="<?= $cmenu['icon'] ?>"></i> <?= $cmenu['menu_name'] ?></a>
                                    <?php else: ?>
                                        <a href="javascript:void(0)"><?= $cmenu['menu_name'] ?><span class="fa arrow"></span></a>
                                        <ul class="nav nav-third-level">
                                            <?php foreach ($cmenu['child_menus'] as $emenu): ?>
                                                <li>
                                                    <?php if (empty($emenu['child_menus'])) : ?>
                                                        <a class="menuItem" href="<?= $emenu['action'] ?>"><i class="<?= $emenu['icon'] ?>"></i> <?= $emenu['menu_name'] ?></a>
                                                    <?php else: ?>
                                                        <a href="javascript:void(0)"><?= $emenu['menu_name'] ?><span class="fa arrow"></span></a>
                                                        <ul class="nav nav-four-level">
                                                            <?php foreach ($emenu['child_menus'] as $fmenu): ?>
                                                                <li>
                                                                    <a class="menuItem" href="<?= $fmenu['action'] ?>">
                                                                        <i class="<?= $fmenu['icon'] ?>"></i>
                                                                        <?= $fmenu['menu_name'] ?>
                                                                    </a>
                                                                </li>
                                                            <?php endforeach;?>
                                                        </ul>
                                                    <?php endif; ?>
                                                </li>
                                            <?php endforeach; ?>
                                        </ul>
                                    <?php endif; ?>
                                </li>
                            <?php endforeach; ?>
                        </ul>
                    </li>
                <?php endforeach; ?>
                <!-- 构建菜单结束 -->
            </ul>
        </div>
    </nav>
    <!--左侧导航结束-->

    <!--右侧部分开始-->
    <div id="page-wrapper" class="gray-bg dashbard-1">
        <div class="row border-bottom content-left" style="border: none!important;">
            <nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
                <div class="navbar-header">
                    <a class="navbar-minimalize minimalize-styl-2" style="color:#FFF;" href="javascript:void(0);"
                       title="收起菜单">
                        <i class="fa fa-bars"></i>
                    </a>
                </div>
                <div class="row content-tabs" style="width: 50%;">
                    <nav class="page-tabs menuTabs">
                        <div class="page-tabs-content">
                            <a href="javascript:;" class="active menuTab" data-id="/backend/dashboard/index">仪表盘</a>
                        </div>
                    </nav>
                </div>
                <ul class="nav navbar-top-links navbar-right welcome-message">
                    <li>
                        <a id="mini-title" style="display: none;">仪表盘</a>
                    </li>
                    <li>
                        <a title="全屏显示" href="javascript:void(0)" id="fullScreen">
                            <i class="fa fa-arrows-alt"></i> 全屏显示
                        </a>
                    </li>
                    <li>
                        <a title="锁屏" href="/backend/index/lock" class="lock-btn">
                            <i class="fa fa-lock"></i> 锁屏
                        </a>
                    </li>
                    <li class="dropdown user-menu">
                        <a href="javascript:void(0)" class="dropdown-toggle" data-hover="dropdown">
                                <span class="hidden-xs">
                                    <?php
                                    echo \support\XunshanContainer::user()->getIdentity()->nickname . ' 欢迎您';
                                    ?></span>
                        </a>
                        <ul class="dropdown-menu">
                            <li class="mt5">
                                <a href="javascript:changePwd();">
                                    <i class="fa fa-key"></i> 修改密码</a>
                            </li>
                            <li class="divider"></li>
                            <li>
                                <a class="logout"
                                   href="javascript:$.modal.confirm('确定退出登录吗？',function(){window.location.href='/backend/login/logout';});">
                                    <i class="fa fa-sign-out"></i> 退出登录</a>
                            </li>
                        </ul>
                    </li>

                </ul>
            </nav>
        </div>

        <a id="ax_close_max" class="ax_close_max" href="javascript:void(0);" title="关闭全屏"> <i
                    class="fa fa-times-circle-o"></i> </a>

        <div class="row mainContent" id="content-main">
            <iframe class="RuoYi_iframe" name="iframe0" width="100%" height="100%" data-id="/backend/dashboard/index"
                    src="/backend/dashboard/index" frameborder="0" seamless></iframe>
        </div>
        <div class="footer">
            <div class="pull-right">© <?= date('Y') ?> <?= params('site_name'); ?></div>
        </div>
    </div>
    <!--右侧部分结束-->
</div>
</body>
<!-- 全局js -->
<script src="/js/jquery.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/ajax/libs/metisMenu/jquery.metisMenu.js"></script>
<script src="/ajax/libs/slimscroll/jquery.slimscroll.min.js"></script>
<script src="/js/jquery.contextMenu.min.js"></script>
<script src="/ajax/libs/blockUI/jquery.blockUI.js"></script>
<script src="/ajax/libs/layer/layer.min.js"></script>
<script src="/xunshan/js/xs-ui.js"></script>
<script src="/xunshan/js/common.js?v=4.1.0"></script>
<script src="/xunshan/index.js"></script>
<script src="/ajax/libs/fullscreen/jquery.fullscreen.js"></script>
<script src="/js/floating.js"></script>

<script>
    $(document).ready(function () {
        initFloating();
    });

    function initFloating() {
        let account = [{
            "type": "Calculator",
            "tip": "计算器",
            "text": "",
            "icon": "fa-calculator",
            "color" : '#ee6100',
            "url": "javascript:void(0);",
            "click": "openCalculator();"
        }];
        let jsonStr = storage.get('xs:menu:list');
        if (jsonStr) {
            let tmp = JSON.parse(jsonStr);
            account = account.concat(tmp);
        }

        let option = {
            "theme": "panel_theme_round_solid",
            "state": true,
            "moveState": false,
            "size": "sm",
            "position": "right-center",
            "tip": {
                "background-color": "#000",
                "color": "#fff"
            },
            "account": account
        };

        $("body").floating(option);
    }

    function openCalculator() {
        layer.open({
            id: 'calculator',
            type: 2,
            title: '计算器',
            maxmin: true,
            shade: 0,
            area: ['520px', '380px'],
            offset: 'rb', //右下角弹出
            anim: 2,
            content: ['/backend/common/calculator', 'no'], //iframe的url，no代表不显示滚动条
            success: function(layero){
                layero.find('.layui-layer-max').hide();
            },
            min: function(layero){
                layero.find('.layui-layer-max').show();
            },
            restore : function(layero){
                layero.find('.layui-layer-max').hide();
            },
        });
        return false;
    }

    function changePwd() {
        //开一个页面修改密码
        var url = '/backend/index/reset-pwd';
        $.modal.open("重置密码", url, '770', '380');
    }

    /** 刷新时访问路径页签 */
    function applyPath(url) {
        $('a[href$="' + decodeURI(url) + '"]').click();
        if (!$('a[href$="' + url + '"]').hasClass("noactive")) {
            $('a[href$="' + url + '"]').parent("li").addClass("selected").parents("li").addClass("active").end().parents("ul").addClass("in");
        }
    }

    $(function () {
        if ($.common.equals("history", mode) && window.performance.navigation.type == 1) {
            var url = storage.get('publicPath');
            if ($.common.isNotEmpty(url)) {
                applyPath(url);
            }
        } else {
            var hash = location.hash;
            if ($.common.isNotEmpty(hash)) {
                var url = hash.substring(1, hash.length);
                applyPath(url);
            }
        }
    });
</script>
</html>
